// pages/select/index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    selectQuestionMenu: '请选择题目类型',
    objectQuestionMenu: {},
    questionMenu: ["选择题", "判断题", "填空题"],
    index: 0,
  },
  /**
    * 选择题库
    */
  changeMenu(e) {
    console.log(e.detail.value);
    console.log(this.data.questionMenu[e.detail.value]);
    this.setData({
      index: e.detail.value,
      selectQuestionMenu: this.data.questionMenu[e.detail.value]
    })
  },


  /**
   * 开始答题
   */
  startAnswer(e) {
    if (this.data.selectQuestionMenu == '请选择题目类型') {
      wx.showToast({
        title: '请选择题目类型',
        duration: 1500,
        image: '/images/warning.png'
      })
      return;
    }
  },

  formSubmit: function (e) {

    var that = this;
    var challenge_type = this.data.selectQuestionMenu;
    wx.request({
      url: "http://localhost:8080/exam/wxExam_Type",
      data: {
        'question_type': challenge_type
      },
      method: "post",

      header: {
        // 'content-type': 'application/x-www-form-urlencoded'
        'content-type': 'application/x-www-form-urlencoded'
      },
      success: function (res) {
        console.log(res.data.question);
        if (res.data.result != null) {
          console.log(res.data.result);
          console.log(res.data.result.question_type);
          console.log(res.data.result.id);

          var idd = JSON.stringify(res.data.result);
          var id = encodeURIComponent(idd);
          console.log(idd);
          if (res.data.result.question_type == '选择题') {
          wx.navigateTo({
            
            url: '../test1/test1?id=' + id
            
          })}
          else if (res.data.result.question_type == '判断题'){
            wx.navigateTo({

              url: '../test2/test2?id=' + id

            })
          }
          else if (res.data.result.question_type == '填空题') {
            wx.navigateTo({

              url: '../test3/test3?id=' + id

            })
          }


        }
      }
    })


  }






})